PRODUCT_NAME = Wi2Geo
BUNDLE_NAME = $(PRODUCT_NAME).app
SOURCES = $(wildcard MapView/*.m) $(wildcard *.m)
ROOTFS = /home/mkrentovskiy/iPhone/rootfs 

CC = arm-apple-darwin-gcc
CXX = arm-apple-darwin-g++
LD = ${CC}

CFLAGS = -Wall -pipe -O3
LDFLAGS = -Wl,-syslibroot,${ROOTFS} \
          -I/usr/local/arm-apple-darwin/include \
          -lobjc \
          -larmfp \
          -framework CoreFoundation \
          -framework Foundation \
          -framework CoreGraphics \
          -framework GraphicsServices \
          -framework UIKit

EXECUTABLE_NAME = $(PRODUCT_NAME)

OBJECTS = \
    $(patsubst %.c,%.o,$(filter %.c,$(SOURCES))) \
    $(patsubst %.cc,%.o,$(filter %.cc,$(SOURCES))) \
    $(patsubst %.cpp,%.o,$(filter %.cpp,$(SOURCES))) \
    $(patsubst %.m,%.o,$(filter %.m,$(SOURCES))) \
    $(patsubst %.mm,%.o,$(filter %.mm,$(SOURCES)))

all: $(PRODUCT_NAME) bundle install

$(PRODUCT_NAME): $(OBJECTS)
	$(LD) $(LDFLAGS) -o $(PRODUCT_NAME) $(OBJECTS)

%.o: %.m
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

clean:
	rm -f *.o $(EXECUTABLE_NAME)
	rm -f *~
	rm -f $(BUNDLE_NAME)/$(EXECUTABLE_NAME)

bundle: $(PRODUCT_NAME)
	cp $(EXECUTABLE_NAME) $(BUNDLE_NAME)/

install:
	scp $(PRODUCT_NAME) root@192.168.1.8:/Applications/$(PRODUCT_NAME).app/$(PRODUCT_NAME)

pack:	bundle
	pack/pack_installer.php
	pack/pack_cydia.php